package com.omi.iberolactalpreventa.objects;

import java.util.ArrayList;

import com.omi.iberolactalpreventa.R;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class AdapterItem_listado_pedidos extends BaseAdapter{

	Activity activity;
	ArrayList<ItmListadoPeds> items;
	
	
	
	public AdapterItem_listado_pedidos(Activity activity,
			ArrayList<ItmListadoPeds> items) {
		this.activity = activity;
		this.items = items;
	}

	@Override
	public int getCount() {
		return items.size();
	}

	@Override
	public Object getItem(int position) {
		return items.get(position);
	}

	@Override
	public long getItemId(int position) {
		return items.get(position).getId();
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) 
	{
		View v = convertView;
		
		if(convertView==null)
		{
			LayoutInflater inf = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			v = inf.inflate(R.layout.item_listado_pedidos, null);
		}
		
		ItmListadoPeds lst = items.get(position);
		TextView txtNumPed = (TextView) v.findViewById(R.id.txtNumPed);
		txtNumPed.setText(lst.getNumPed());
		TextView txtFechaPed = (TextView) v.findViewById(R.id.txtFechaPed);
		txtFechaPed.setText(lst.getFechaPed());
		TextView txtRefPed = (TextView) v.findViewById(R.id.txtRefPed);
		txtRefPed.setText(lst.getRef());
		TextView txtNombreClientPed = (TextView) v.findViewById(R.id.txtNombreClientPed);
		txtNombreClientPed.setText(lst.getNombreClient());
		return v;
	}

}
